traceroute命令

traceroute命令尝试跟踪IP数据包到某个Internet主机的路由,方法是使用一个小ttl(生存时间)启动探测数据包,然后侦听来自网关的ICMP超时回复,它以ttl1开始探测,并将其增加1,直到获得ICMP port unreachableTCP reset,这意味着我们到达了host,或达到了最大值(默认为30跳),在每个ttl设置处发送三个探测(默认),并打印一行,显示ttl、网关地址和每个探测的往返时间,在请求时,地址后面可以有附加信息,如果探测结果来自不同的网关,则会打印每个响应系统的地址,如果在5.0秒内(默认值)没有响应,则会为该探测器打印一个*

语法

traceroute [-46dFITUnreAV] [-f first_ttl] [-g gate,...] [-i device] 
           [-m max_ttl] [-p port] [-s src_addr] [-q nqueries] 
           [-N squeries] [-t tos] [-l flow_label] [-w waittime] 
           [-z sendwait] [-UL] [-D] [-P proto] [--sport=port] [-M method] 
           [-O mod_options] [--mtu] [--back] host [packet_len]

参数

示例

使用traceroute查看路由信息。

traceroute www.google.com

指定IPv4查看路由信息。

traceroute -4 www.google.com

指定要启动的TTL,默认为1

traceroute -f 3 www.google.com

不将IP地址解析为其域名。

traceroute -n www.google.com

设置每个跃点的探测数,默认为3

traceroute -q 1 www.google.com

指定完整的数据包长度,默认是60字节的数据包。

traceroute www.google.com 100

设置要使用的目标端口,默认为33434

traceroute -p 20292 www.google.com

参考

https://www.computerhope.com/unix/utracero.htm
https://www.runoob.com/linux/linux-comm-traceroute.html
https://www.geeksforgeeks.org/traceroute-command-in-linux-with-examples/